<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Holidays</title>
<!-- Bootstrap core CSS -->
<link href="<c:url value="/resources/css/bootstrap.min.css"></c:url>"
	rel="stylesheet" />
<link href="<c:url value="/resources/css/bootstrap-reset.css"></c:url>"
	rel="stylesheet" />
<!--external css-->
<link
	href="<c:url value="/resources/assets/font-awesome/css/font-awesome.css"></c:url>"
	rel="stylesheet" />
<!-- Custom styles for this template -->
<link href="<c:url value="/resources/css/style.css"></c:url>"
	rel="stylesheet" />
<link href="<c:url value="/resources/css/style-responsive.css"></c:url>"
	rel="stylesheet" />

<link
	href="<c:url value="/resources/assets/advanced-datatable/media/css/demo_table.css"></c:url>"
	rel="stylesheet" />
</head>
<body>
	<jsp:useBean id="rowsLimit" class="java.util.ArrayList">
		<%
			rowsLimit.add(5);
				rowsLimit.add(10);
				rowsLimit.add(15);
				rowsLimit.add(20);
		%>
	</jsp:useBean>
	<section class="panel">
	<div class="panel-body">
		<form method="post" id="frmHolidayList">
		<header class="panel-heading">
			Holidays</header>
			<div class="adv-table">
				<div id="hidden-table-info_wrapper" class="dataTables_wrapper"
					role="grid">
					<div id="hidden-table-info_length" class="dataTables_length">
						<label>Show <select class="form-control" size="1"
							aria-controls="hidden-table-info" name="cboRows" onchange="formSubmit();">
															<c:if test="${criteria.rowLimit > 0 }">
									<option value="${criteria.rowLimit }">${criteria.rowLimit }</option>
								</c:if>
								<c:forEach items="${rowsLimit }" var="row">
									<c:if test="${row != criteria.rowLimit}">
										<option value="${row }">${row }</option>
									</c:if>
								</c:forEach>
							</select>
						</label> <a href="${pageContext.request.contextPath }/holidays/new"
							class="btn btn-primary">New</a>
					</div>
					<div class="dataTables_filter" id="hidden-table-info_filter">
						<label>Search: <input type="text" id="txtKeyword" class="form-control"
							aria-controls="hidden-table-info" name="keyword"
							value="${criteria.keyword }"><button style="visibility: hidden;"></button></label>
					</div>
					<table class="table">
						<thead>
							<tr>
								<th>Date</th>
								<th>Description</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${holidayList }" var="holiday">
								<tr>
									<td><fmt:parseDate var="fmtDate"
											value="${holiday.holiday }" pattern="yyyyMMdd"></fmt:parseDate>
										<a
										href="${pageContext.request.contextPath }/holidays/${holiday.holiday}"><fmt:formatDate
												value="${fmtDate }" pattern="dd/MM/yyyy" /></a></td>
									<td>${holiday.description }</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					<div class="dataTables_paginate paging_two_button"
						id="hidden-table-info_paginate">
						<c:if test="${criteria.rowIndex == 0 }">
							<button class="btn btn-warning" name="btnPrev" disabled>Previous</button>
						</c:if>
						<c:if test="${criteria.rowIndex > 0 }">
							<button class="btn btn-warning" name="btnPrev">Previous</button>
						</c:if>
						<c:choose>
							<c:when
								test="${(criteria.rowIndex + criteria.rowLimit) >= criteria.recordCount }">
								<button class="btn btn-warning" name="btnNext" disabled>Next</button>
							</c:when>
							<c:otherwise>
								<button class="btn btn-warning" name="btnNext">Next</button>
							</c:otherwise>
						</c:choose>
					</div>
					<input type="hidden" value="${criteria.rowIndex }" id="rowIndex" name="rowIndex" />
				</div>
			</div>
		</form>
	</div>
	</section>
	<!-- js placed at the end of the document so the pages load faster -->
	<script src="<c:url value="/resources/js/jquery.js"></c:url>"></script>
	<script src="<c:url value="/resources/js/bootstrap.min.js"></c:url>"></script>
	<script class="include" type="text/javascript"
		src="<c:url value="/resources/js/jquery.dcjqaccordion.2.7.js"></c:url>"></script>
	<script
		src="<c:url value="/resources/js/jquery.scrollTo.min.js"></c:url>"></script>
	<script
		src="<c:url value="/resources/js/jquery.nicescroll.js"></c:url>"
		type="text/javascript"></script>
	<script src="<c:url value="/resources/js/respond.min.js"></c:url>"></script>

	<!--common script for all pages-->
	<script src="<c:url value="/resources/js/common-scripts.js"></c:url>"></script>
	<script>
	function formSubmit() {
		document.getElementById("rowIndex").value = 0;
		document.getElementById("frmHolidayList").submit();
	}
	$(function(){
		$("#txtKeyword").keypress(function(e){
			
			if(e.which == 13){
				formSubmit();
			}
		});
	});
</script>
</body>
</html>